<%@ include file="database_ini.jsp"%>
<%!
String blanknull(String s) {
  return (s == null) ? "" : s;
}
%>
<CENTER>


<p>
<%

	String listname=request.getParameter("listname");
	String code=request.getParameter("code");
	String description=request.getParameter("description");
	String short_value=request.getParameter("short");
	String long_value=request.getParameter("long_value");
	String notes=request.getParameter("notes");
	
	
	//debug out.println(listname);
	if(request.getParameter("insert") != null){
		String sql = "insert into codelkup (listname, code, description, short, long_value,  notes) values (?,?,?,?,?,?)";
		pstmt = conn.prepareStatement(sql);

		pstmt.setString(1 , blanknull(listname));
		pstmt.setString(2 , blanknull(code));
		pstmt.setString(3 , blanknull(description));
		pstmt.setString(4 , blanknull(short_value));
		pstmt.setString(5 , blanknull(long_value));
		pstmt.setString(6 , blanknull(notes));
		pstmt.executeUpdate();
		response.sendRedirect("application.jsp?listname="+listname);
	
	//		out.print("Insert success! return index.jsp after 3 seconds!");
	//		response.setHeader("Refresh" , "3;url=application.jsp?listname=" + listname);
}
%>
<a href="index.jsp"><font size="3">Home</font></a>

<form action = "insert.jsp" method = "post"> 
<table border="1">
<tr><th>listname</th><th>code</th><th>description</th><th>short</th><th>long_value</th><th>notes</th></tr>
<tr>
<td><input type="text" name="listname" size="10" readonly="readonly" value="<%=listname%>"></td>
<td><input type="text" name="code" maxlength="10" size="5" value=""></td>
<td><input type="text" name="description" maxlength="250" size="10" value=""></td>
<td><input type="text" name="short" maxlength="30" size="20" value=""></td>
<td><input type="text" name="long_value" maxlength="250" size="20" value=""></td>
<td><input type="text" name="notes" maxlength="2000" size="20" value=""></td>
</tr>
<tr>
<td><input type="submit" name="insert" value="insert" style="background-color:#49743D;font-weight:bold;color:#ffffff;"></td>
<td></td>
<td><a href="application.jsp?listname=<%=listname%>" ><font size="3">Back</font></a></td>
<td></td>
<td></td>
<td></td>
</tr>

</table>
</form>
</CENTER>